<template>
    <div id="collectAll">
        <scroller snappingHeight="10" class="scroller" :on-refresh="refresh" :on-infinite="infinite" ref="my_scroller">
            <div class="receiveitem" v-for="(item,index) in myRecList" :key="index">
                <div class="userinfo">
                    <i><img :src="baseUrl.baseUrl+item.cplogo"></i>
                    <p>{{item.cname}}</p>
                </div>
                <!-- <div class="icons">
                    <a class="" href="#" class="fo-right"><i class="iconfont icon-yiguanzhu"></i><label >{{item.dconfirmdate?'已交换':'待确认'}}</label></a>
                </div> -->
            </div>
        </scroller>
    </div>
</template>

<script>

import {recommendLists} from '../../../../js/dataServe.js'
import {baseUrl} from '../../../../config/env.js'
export default {
    data(){
        return {
            pageNo:1,
            myRecList:[],
            baseUrl:{baseUrl}
        }
    },
    components:{},
    created(){
        // this.$store.commit('changeShowit',{val:false})
    },
    mounted(){
        
    },
    methods:{
        // //获取推荐列表
        infinite(done) {

            if(sessionStorage.sid){
                let self = this;
                let responseData = recommendLists(self.pageNo);
                responseData.then((res)=>{
                                        // alert(decodeURIComponent(res.msg))
                                        if(res.data && res.data.list.length>0){
                                           
                                            let items = res.data.list;
                                            // console.log(items)
                                            items.forEach( (item,key) => {
                                                if(item.uid == sessionStorage.uid && self.myRecList.indexOf(item)<0){
                                                    self.myRecList.push(item)
                                                }
                                            })
                                            self.pageNo++;
                                            done();
                                            
                                        }else{
                                            self.$refs.my_scroller.finishInfinite(2);
                                        }
                                    })
            }
        },
        refresh(done) {
            done()
        },
    }
}
</script>

<style scoped >
#collectAll {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    width: 100%;
    height: auto;
    bottom: 0;
    top: 6rem;
    position: absolute;
}
.receiveitem{
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #dfdfdf;
}
.userinfo{
    display:flex;
}
.receiveitem i{
    width:4rem;
    height:4rem;
    display:block;
}
.receiveitem p{
    height:4rem;
    line-height:4rem;
    margin-left:1rem;
}
.receiveitem i img{
    width:100%;
    height:100%;
    border-radius:5rem;
}
.icons{
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.icons a{
    display: flex;
    flex-direction: column;
}
.icons a i,.icons a label{
    height:1.2rem;
    line-height:1.2rem;
}
</style>
